package view;

import java.awt.Graphics;

import model.Model;
import util.Direction;
import util.MyPosition;

public class TankView extends ModelView {
    private BloodView bloodView;

    public TankView(MyPosition myPosition, Model model) {
        super(myPosition, model);
        bloodView = new BloodView(position, model);
        dirStatic = Direction.STOP;
    }

    // 绘画
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        setBounds(position.getX(), position.getY(), position.getWidth(), position.getHeight());
        g.setColor(color);
        g.fillOval(0, 0, position.getWidth(), position.getHeight());
    }

    @Override
    public void stay() {
        setPosition(oldPosition);
    }

    // set&get
    @Override
    public void setPosition(MyPosition position) {
        oldPosition = new MyPosition(this.position);
        this.position = new MyPosition(position);
        bloodView.setPosition(position);
        repaint();
    }

    public void changeBlood(double mode) {
        bloodView.setMode(bloodView.getMode() - mode);
    }

    public BloodView getBloodView() {
        return bloodView;
    }
}
